package control;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Utils {

	public static Date getDateFromString(String dateInString)
	{
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm");
		
		Date date = null;
		try {
			date = formatter.parse(dateInString);
		} catch (ParseException e) {
			System.out.println("Erreur de parsing de la date");
		}
		return date;
		
	}
	
	public static List<Integer> getListIntegerFromString(String liste)
	{
		List<Integer> resusltat = new ArrayList<Integer>();
		String[] split = liste.split("-");
		
		for(String idString : split)
		{
			resusltat.add(Integer.parseInt(idString));
		}
		
		return resusltat;
	}
	
	
	
	


	public static Date getHourFromString(String hourInString)
	{
		SimpleDateFormat formatter = new SimpleDateFormat("HH-mm");
		Date date = null;
		try {
			date = formatter.parse(hourInString);
		} catch (ParseException e) {
			System.out.println("Erreur de parsing de la date");
		}
		return date;
	}
	
	
	public static void main(String[] args) {
		System.out.println(getHourFromString("22-30"));

	}
}
